<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link type="text/css" rel="stylesheet" href="${createLinkTo(dir:'css/csslxh',file:'lxh.css')}">
	<script type="text/javascript" src="${createLinkTo(dir:'js',file:'lxh.js')}"></script>
</head>
<script language="javascript">
function doSubmit()
{
	var menuIds = getCheckboxValue("menuId");

	if(menuIds == "")
	{
		alert("角色选项不能为空");
		return false;
	}
	myform.menus.value = menuIds;
	myform.id.value = "${roleinfo.id}";
	myform.submit();
}

</script>
<body>
<g:form name="myform" controller="roleinfo" action="roleUpdate" method="post">
<input type="hidden" name="id">
<input type="hidden" name="menus">

<table align="center" width="500" style="border-left:2px solid orange;border-right:2px solid orange;">
	<tr><td>&nbsp;</td></tr>
	<tr>
		<td>
 			<table align="center" class="tableGray" cellspacing="1" style="width:300px">
				<tr>
					<td valign="bottom" bgcolor="#ffffff">
						角色名称：<input type="text" name="rolename" value="${roleinfo.rolename}" class="textUnderline" size="30">
					</td>
				</tr>
				<tr>
					<td valign="bottom" bgcolor="#ffffff">
						角色描述：<input type="text" name="memo" value="${roleinfo?.memo}" class="textUnderline" size="30">
					</td>
				</tr>
			    <tr><td>全选：<input type="checkbox" onclick="seleAll('menuId', this.checked)"></td></tr>
			    
				<%
				def idx = 0;
				def bgcolor = "";
				for(m1 in m1List){
					if( (++idx)%2 != 0 )
					{
						bgcolor = "#f6f6f6"
					}else
					{
						bgcolor = "";
					}
				%>
				<tr>
					<td bgcolor="${bgcolor}">
						${m1?.menuname}
						<%
						def m2List = m2Map[m1?.id];
						for(m2 in m2List){
						%>
						<br>&nbsp;&nbsp;&nbsp;<g:if test="${m2.isleaf == 1}"><input type="checkbox" name="menuId" value="${m2.id}"></g:if>${m2.menuname}
							<%
							def m3List = m3Map[m2?.id];
							for(m3 in m3List){
							%>
							<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="menuId" value="${m3.id}">${m3.menuname}
							<%}%>
									
						<%}%>
					</td>
				</tr>
				<%}%>
				
				<tr>
				    <td align="center" bgcolor="#ffffff" style="height:35">
				    	<input type="button" value="修改" class="btnGray" onclick="doSubmit()">&nbsp;
				    	<input type="button" value="取消" class="btnGray" onclick="history.back()">
				    </td>
				</tr>
			</table>
	
		</td>
	</tr>
	<tr><td>&nbsp;</td></tr>
</table>


</g:form>
</body>
<script language="javascript">
function doChecked()
{
	var menus = "${roleinfo.menus}";
	var menusArray = menus.split(",");
	var didStr = "";
	for(i=0; i < menusArray.length; i++)
	{
		didStr += "["+menusArray[i]+"]";
	}
	
	names = document.getElementsByName("menuId");
	for(var i = 0; i < names.length; i++)
	{
		if(didStr.indexOf("["+names[i].value+"]")!=-1)
		names[i].checked = true;
	}
}
doChecked();
</script>
</html>